	
-- ***********************************************************************************************
-- GETUPDATECONFLICT Stored Procedures for the list of tables mentioned in the Initialize file
--------------------------------------------------------------------------------------------------

--TABLE NAME: Customer    STORED PROCEDURE NAME: Sales.sync_sp_Customer_GetUpdateConflict

use [SyncSamplesDb_ChangeTracking_Custom]

if object_id(N'Sales.sync_sp_Customer_GetUpdateConflict', 'P') is not null
	drop procedure Sales.sync_sp_Customer_GetUpdateConflict
GO

	create procedure Sales.sync_sp_Customer_GetUpdateConflict(
        @CustomerId uniqueidentifier       
        )
as
	SELECT		E.CustomerId
				, E.CustomerName
				, E.SalesPerson
				, E.CustomerType
				, CT.SYS_CHANGE_CONTEXT
				, CT.SYS_CHANGE_VERSION 
	FROM		[SyncSamplesDb_ChangeTracking_Custom].[Sales].[Customer] AS E
	JOIN		CHANGETABLE(VERSION [SyncSamplesDb_ChangeTracking_Custom].[Sales].[Customer], ([CustomerId]), (@CustomerId)) AS CT  
				ON E.CustomerId = CT.CustomerId

GO

-------------------------------------------END------------------------------------------------------------------
